<?php
/**
 * Zhub - A PHP Framework For API Developer
 *
 * This file is part of the Zhub package.
 *
 * (c) YiLong Fan <fantiq@163.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author fanyilong <fantiq@163.com>
 * @copyright 2017 fanyilong. All rights reserved.
 * @package Zhub
 * @date 18-2-11
 */

namespace Zhub\DataStruct;


abstract class Enum
{
    abstract public static function initialize():array ;

    public static function values():array
    {
        return static::initialize();
    }

    public static function id($msg):?int
    {
        $id = array_search($msg, static::initialize(), true);
        return $id === false ? null : $id;
    }

    public static function name($id)
    {
        return static::initialize()[$id] ?? null;
    }
}